﻿using GCC.Container.Common.Models;

namespace GCC.Container.Common
{
    /// <summary>
    /// 容器配置管理
    /// </summary>
    public class ContainerConfigManager
    {
        /// <summary>
        /// 当前容器的版本
        /// </summary>
        public static readonly Version CurrentVersion = new("1.0.0.0");
        /// <summary>
        /// 配置管理器实例
        /// </summary>
        public static readonly ContainerConfigManager Instance = new();
        /// <summary>
        /// 配置内容
        /// </summary>
        public ContainerConfig Config { get; init; } = new ContainerConfig();
        /// <summary>
        /// 构造函数
        /// </summary>
        private ContainerConfigManager()
        {
            var path = Path.Combine(AppContext.BaseDirectory, "containerConfig.json");
            if (File.Exists(path))
            {
                var info = System.Text.Json.JsonSerializer.Deserialize<ContainerConfig>(File.ReadAllText(path), LuanNiao.JsonConverterExtends.CommonSerializerOptions.CamelCaseChineseNameCaseInsensitive);
                if (info is not null)
                {
                    Config = info;
                }
            }
        }



    }
}
